//  WithdrawApply.js
const app = getApp()
const util = require("../../utils/util.js")
import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    status:'pending',
    statuschoose:'pending',
    statusShow:false,
    pagenum: 1

    // 同意提现 = "approval";
    // 拒绝提现 = "cancel";
    // 等待提现 = "pending";
  },
  statuspop() {
    this.setData({ statusShow: true });
  },
  statusClose() {
    this.setData({ statusShow: false });
  },
  radioChange(event) {
    this.setData({
      statuschoose: event.detail
    });
    this.statusTap();
  },
  // 获取列表
  review: function () {
    var that = this;
    var data = {
      page: that.data.pagenum,
      value: '',
      status: that.data.status,
      type: app.globalData.userInfo.type
    };
    app.post('weixin/withdrawalRecord', data).then((res) => {
      if (res.code == 200) {
        var list = that.data.list;
        var dataArr = res.entity.content;
        list = list.concat(dataArr)
        that.setData({
          list: list,
          total: res.entity.totalElements
        })
      }
    }).catch((errMsg) => {
      console.log(errMsg);
      wx.showToast({
        title: "网络错误",
        icon: 'loading',
        duration: 2000
      })
    })
  },
  statusTap:function(){
    var that = this;
    that.setData({
      statusShow: false,
      status: that.data.statuschoose,
      pagenum: 1,
      list:[]
    });
    that.review();
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.review();
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.setData({
      list: [],
      pagenum: 1
    })
    this.review();
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this;
    var pagenum = that.data.pagenum + 1; //获取当前页数并+1
    that.setData({
      pagenum: pagenum, //更新当前页数
    })
    that.review();
  }

})